package com.project.petLossSystem.service.impl;

import com.project.petLossSystem.mapper.AdminMapper;
import com.project.petLossSystem.po.Admin;
import com.project.petLossSystem.service.AdminService;
import com.project.petLossSystem.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin login(String loginId, String loginPassword) {
        String passwordMD5 = MD5Util.MD5Encode(loginPassword, "UTF-8");
        return adminMapper.login(loginId, passwordMD5);
    }

    @Override
    public boolean updatePasswordById(Integer adminId, String password) {
        password = MD5Util.MD5Encode(password, "UTF-8");
        return adminMapper.updatePasswordById(adminId, password) > 0;
    }

    @Override
    public boolean updateLoginIdAndNameById(Integer adminId, String loginId, String name) {
        return adminMapper.updateLoginIdAndNameById(adminId, loginId, name) > 0;
    }


}
